//
//  PlayNavigationController.m
//  聆听FM
//
//  Created by dllo on 16/6/16.
//  Copyright © 2016年 Dark. All rights reserved.
//

#import "PlayNavigationController.h"
#import "LTTabBarPlayButtonView.h"
#import "ZCSPlayMusicViewController.h"
#import "LTArchiverTools.h"
#import "LTLastMusicModel.h"
#import "ZCSListenListListModel.h"
#import "LJLRadioPageModel.h"
@interface PlayNavigationController ()<LTTabBarPlayButtonViewDelegate>
@property (nonatomic,retain) LTTabBarPlayButtonView *playView;
@property (nonatomic,copy) NSString *imageName;
@property (nonatomic, retain) LTLastMusicModel *lastModel;
@end

@implementation PlayNavigationController
- (void)dealloc
{
    // 关闭消息中心
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // 开启两个通知接收(LXMyCenterViewController传入)
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hidePlayView:) name:@"hidePlayView" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showPlayView:) name:@"showPlayView" object:nil];
    
    self.playView = [[LTTabBarPlayButtonView alloc] init];
    self.playView.delegate = self;
    [self.view addSubview:_playView];
    
    self.playView.frame = CGRectMake(155 * FITWIDTH, SCREENHEIGHT - 65, 65, 65);
    NSDictionary *tempDic = [LTArchiverTools unarchiverObjectByKey:@"lastMusic" WithPath:@"lastMusic.plist"];
    _lastModel = [[LTLastMusicModel alloc] initWithDic:tempDic];
    if (tempDic) {
      NSString *photoUrl = [[NSUserDefaults standardUserDefaults] objectForKey:@"photo"];
        [self.playView.contentImageView sd_setImageWithURL:[NSURL URLWithString:photoUrl] placeholderImage:[UIImage sd_animatedGIFNamed:@"占位图"]];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"pause" object:nil];
    }
}
- (void)playButtonDidClick:(BOOL)isSelected
{
    ZCSPlayMusicViewController *play = [ZCSPlayMusicViewController sharePlayVC];
    [self presentViewController:play animated:YES completion:nil];

}

// 隐藏图片
- (void)hidePlayView:(NSNotification *)notification
{
    self.playView.hidden = YES;
}

// 显示图片
- (void)showPlayView:(NSNotification *)notification
{
    self.playView.hidden = NO;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
